#!/usr/bin/python
# -*- coding: UTF-8 -*-
import urllib
import urllib2


class TestBase:

    def testOne(self):
        urlopen = urllib2.urlopen("http://www.baidu.com")
        print urlopen.read()

    def testRequest(self):
        request = urllib2.Request("http://www.baidu.com")
        response = urllib2.urlopen(request)
        read = response.read()
        print read

    def testPost(self):
        values = {"username": "cankuan7963", "password": "tutukmvn"}
        data = urllib.urlencode(values)
        url = "https://passport.csdn.net/account/login?from=http://my.csdn.net/my/mycsdn"
        request = urllib2.Request(url, data)
        response = urllib2.urlopen(request)
        print response.read()

if __name__ == '__main__':
    base = TestBase()
    # base.testOne()
    # base.testRequest()
    base.testPost()